unit uFormMain;

interface

uses
  Windows, Messages, SysUtils, Variants,
  Classes, Graphics, Controls, Forms, dialogs,
  uPluginIntf, StdCtrls;

type

  TForm_Main = class(TForm,IPluginable)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Edit_VariableName: TEdit;
    Edit_VariableValue: TEdit;
    Memo_InitString: TMemo;
    Memo_ClientConfig: TMemo;
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private


    { Private declarations }
  protected
    FPlugin : IPlugin;

    procedure SetPlugin(APlugin : IPlugin);
    function GetPlugin:IPlugin;
  public

    { Public declarations }
    property Plugin : IPlugin read GetPlugin write SetPlugin;
  end;

var
  Form_Main: TForm_Main;
implementation

{$R *.dfm}


procedure TForm_Main.FormDestroy(Sender: TObject);
var
  lClientConfig : TStrings;
begin
  lClientConfig := TStringList.Create;
  //lClientConfig.Values['ClientParams'] := Edit_ClientParams.Text;

  //GetPlugin.HostParams := lClientConfig.Text;  //save to db

  lClientConfig.Free;

  Plugin.HostParams := Memo_ClientConfig.Lines.Text;

  { TODO -oyou -cplugin-template : fill finalization code here }
end;

function TForm_Main.GetPlugin: IPlugin;
begin
  Result := FPlugin;
end;

procedure TForm_Main.SetPlugin(APlugin: IPlugin);
var
  lClientConfig : TStrings;
  lPrintPort : String;
begin
  //save the plugin if need
  FPlugin :=APlugin;

  //init code here.

  //how to get client-config
  lClientConfig := TStringList.Create;
  //lClientConfig.Text := GetPlugin.HostParams;
//  Edit_ClientParams.Text := lClientConfig.Values['ClientParams'];

  lClientConfig.Free;

  Memo_ClientConfig.Lines.Text := Plugin.HostParams;

  //how to get soap address by context variable, see more RS_xxx by CTL + LeftClick
  //FSoapAddr := FPlugin.Variable[RS_DEFAULT_MODULE_SOAP_ADDR];


  //how to get initialzation info
  Memo_InitString.Lines.Text := Plugin.InitString;

end;

procedure TForm_Main.Button1Click(Sender: TObject);
begin
  Edit_VariableValue.Text := Plugin.Variable[Edit_VariableName.Text];
end;

end.
